package com.ruoyi.edh.config;

import com.github.wxpay.sdk.WXPay;
import com.github.wxpay.sdk.WXPayConfig;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;

/**
 * @version :
 * @program: shipCargoEasyLink
 * @description: 微信支付配置
 * @author: 周爱鸿
 * @create: 2020-08-14 10:15
 **/
@Configuration
public  class WxPayConfig implements WXPayConfig {
	private byte[] certData;

	public WxPayConfig() throws IOException {
	/*	String certPath = "C:\\Users\\Shinelon\\Desktop\\pfkProject\\shipCargoEasyLink\\shipCargoEasyLink\\ruoyi-admin\\src\\main\\resources\\pay\\apiclient_cert.p12";
		File file = new File(certPath);
		InputStream certStream = new FileInputStream(file);
		this.certData = new byte[(int) file.length()];
		certStream.read(this.certData);
		certStream.close();*/
	}

	@Bean(name = "wxPay")
	public WXPay wxPay(){
		return new WXPay(this);
	}

	@Override
	public String getAppID() {
		return "wx7f69493ad4f4982e";
	}

	/**
	 * 商户号
	 */
	@Override
	public String getMchID() {
		return "1592810831";
	}

	/**
	 * 支付32位密钥
	 */
	@Override
	public String getKey() {
		return "e8fc35d9af9b7b89c2d9ca62cd64e62f";
	}

	@Override
	public InputStream getCertStream() {
		ByteArrayInputStream certBis = new ByteArrayInputStream(this.certData);
		return certBis;
	}

	@Override
	public int getHttpConnectTimeoutMs() {
		return 8000;
	}

	@Override
	public int getHttpReadTimeoutMs() {
		return 10000;
	}

}
